package org.example.controller;


import com.alibaba.fastjson.JSON;
import jakarta.annotation.Resource;
import org.example.feign.AuthFeign;
import org.example.pojo.AuthInfo;
import org.example.pojo.Respond;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashSet;
import java.util.UUID;

@RestController
@RequestMapping("/gateway")
public class AuthControllerGateway {


    @Resource
    AuthFeign authFeign;

    @RequestMapping(value = "/register",method = RequestMethod.POST)
    public Respond<String> register(String router, @RequestBody AuthInfo authInfo){
        String auth = JSON.toJSONString(authInfo);
        return null;
    }

    @GetMapping("/test")
    public Respond<String> test(){
        HashSet<String> roles = new HashSet<>();
        roles.add("admin");
        roles.add("visitor");
        AuthInfo authInfo = new AuthInfo(true, false, new UUID(12,12).toString(), roles,1);
        String jsonString = JSON.toJSONString(authInfo);
        return authFeign.register("/httpTest", jsonString);
    }
}
